#include <bits/stdc++.h>
using namespace std;


#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;
typedef pair<LL, LL> P;

P s, t;

const int nxtx[] = {-1, 2, 4, 1, 3},
nxty[] = {-1, 4, 3, 2, 1};

inline LL manDistance(P a, P b)
{
	return llabs(a.first - b.first) + llabs(a.second - b.second);
}

int trans(P p)
{
	P res(p.first % 5, p.second % 5);
	// dbg(res.first, res.second);
	res.second = (res.second + 5 - res.first * 3 % 5) % 5;
	res.first = 0;
	res.second = (res.second % 5 + 5) % 5;
	// dbg(res.first, res.second);
	return (int)res.second;
}
	
inline LL extend(LL x, LL y) // y > x
{
	return (y - x + 4) / 5 * 2;
}
 
LL right(P s, P t)
{
	int sp = trans(s);
	dbg(sp);
	P delt(t.first-s.first, t.second-s.second);
	LL base = manDistance(s, t);
	// still need to down
	LL finalx = s.first + nxtx[sp] - 1 + delt.second * 2;
	LL ans = base;
	if (finalx < t.first)
	{
		ans = base + extend(finalx, t.first);
	}

	dbg(1, base, finalx, ans);

	// still need to right
	LL finaly = s.second + nxty[sp] -1 + delt.first * 3;
	if (finaly < t.second)
	{
		ans = base + extend(finaly, t.second);
	}

	dbg(2, ans);
	return ans;
}

LL left(P s, P t)
{
	int sp = trans(s);
	
	P delt(t.first - s.first, s.second - t.second);
	LL base = manDistance(s, t);

	LL ans = base;
	// still need to down
	LL finalx =  s.first + nxtx[sp] + delt.second * 3;
	if (finalx < t.first)
	{
		ans = base + extend(finalx, t.first);
	}
	dbg(3, ans);

	// still need to left
	LL finaly = s.second + nxty[sp] - 5 - delt.first * 2;
	if (t.second < finaly)
	{
		ans = base + extend(t.second, finaly);
	}
	dbg(4, finaly, ans);
	return ans;
}

int main(int argc, char const *argv[])
{
	cin >> s.first >> s.second >> t.first >> t.second;
	if (s.first > t.first)
		swap(s, t);

	LL ans = manDistance(s, t);

	if (s.second <= t.second)
		ans = max(ans, right(s, t));
	else
		ans = max(ans, left(s, t));

	printf("%lld\n", ans);

	return 0;
}